package com.usian.model.base;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.PageRequestDto;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import org.apache.commons.lang3.StringUtils;


public class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M,T> {

    public ResponseResult errorParam = ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);

    public ResponseResult succes =  ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);

    public ResponseResult needLogin =  ResponseResult.errorResult(AppHttpCodeEnum.NEED_LOGIN);


    protected ResponseResult getPageData(PageRequestDto dto, Wrapper wrapper){
    //2.安装名称模糊分页查询
    Page page = new Page(dto.getPage(),dto.getSize());

    IPage result = page(page, wrapper);

    //3.结果封装
    ResponseResult responseResult = new PageResponseResult(dto.getPage(),dto.getSize(),(int)result.getTotal());
    responseResult.setData(result.getRecords());
    return responseResult;

}

public ResponseResult getSucces(){
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
}



public ResponseResult paramError(){
        return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
}

}
